<?php
use yii\helpers\Url;
use yii\web\View;
use app\assets\SolutionAsset;
/* @var $this yii\web\View */
SolutionAsset::register($this); 
$this->title = $this->context->pageTitle.Yii::$app->params['titleSuffix'];
$this->params['breadcrumbs'] = [
  \Yii::t('solution', 'Solution'),
  \Yii::t('common', 'Data')
];
$jsMsgs = $this->context->loadJsMsgs([
  'table',
  'solution',
  'dialog',
  'listOp'
]);
$this->registerJs("VAM.setVar('LANGUAGE_JS', '".$jsMsgs."');", View::POS_HEAD);
?>
<div class="page-header">
  <h1>
    <?=\Yii::t('solution', 'Solution')?>
    <small><?=\Yii::t('solution', 'Solution List')?></small>
    <div class="btn-group btn-group-sm pull-right" role="group" aria-label="...">
      <div class="text-error btn hidden" id="all_tip">
        <?=\Yii::t('common', 'Please select the brand for add!')?>
      </div>
  <?php
// 		$loading = \Yii::t('common', 'Loading').'...';
// 		$pcUrl = Url::to(['new-pc-solution-basic']);
// 		$pcSolution = \Yii::t('solution', 'New PC Solution');
// 		$pcDiv = <<<FINE
//       <a href="$pcUrl" class="btn btn-primary new-operate-btn" data-loading-text="<i class='fa fa-spinner fa-spin'></i> $loading" id="new-operate-btn">
//         <i class="fa fa-plus-circle"></i>
// 		$pcSolution
//       </a>
// FINE;
// 		if (in_array(1, $_SESSION['traffic_slot']) || in_array(2, $_SESSION['traffic_slot'])) echo $pcDiv;
	?>
	<?php
		$loading = \Yii::t('common', 'Loading').'...';
		$mobUrl = Url::to(['new-solution-basic']);
		$mobSolution = \Yii::t('solution', 'New Solution');
		$mobDiv = <<<FINE
      <a href="$mobUrl" class="btn btn-success new-operate-btn" data-loading-text="<i class='fa fa-spinner fa-spin'></i> $loading" id="new-operate-btn">
        <i class="fa fa-plus-circle"></i>
        $mobSolution
      </a>
FINE;
		if (in_array(3, $_SESSION['traffic_slot']) || in_array(4, $_SESSION['traffic_slot'])) echo $mobDiv;
	 ?>
    </div>
  </h1>
</div>
<div class="panel panel-default">
  <div class="panel-heading"> 
    <i class="fa fa-table"></i>
    <?=\Yii::t('solution', 'Solution List')?>
    <ul class="list-inline list-unstyled pull-right">
      <li>
        <a class="data-table-refresh" href="#" title="<?=\Yii::t('common', 'Click to refresh data')?>">
          <i class="fa fa-refresh"></i>
        </a>
      </li>
      <li>
        <a href="#">
          <i class="fa fa-chevron-up"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="panel-body pos-r">
    <div id="list-loading-wrap" class="local-loading-wrap"></div>
    <div class="table-responsive">
      <table class="table table-hover table-striped table-bordered table-condensed" id="data-table" data-tag="vm-adserver.solution-list">
        <thead class="heading">
          <tr>
            <th class="" data-resizable-column-id="id" data-search="on" data-filter="on">ID</th>
            <th data-resizable-column-id="name" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Name')?></th>
            <th data-resizable-column-id="launch" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Campaign')?></th>
            <th data-resizable-column-id="status" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Status')?></th>
            <!-- <th data-resizable-column-id="type" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Solution Type')?></th> -->
            <th data-resizable-column-id="launchTime" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Solution Time')?></th>
            <th data-resizable-column-id="creativeCount" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Creative Num')?></th>
            <th data-resizable-column-id="dailyBudget" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Today Budget')?></th>
            <th data-resizable-column-id="cost" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Today Cost')?></th>
            <th data-resizable-column-id="dailyRate" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Today Progress')?></th>
            <th data-resizable-column-id="totalBudget" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Total Budget')?></th>
            <th data-resizable-column-id="totalCost" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Total Cost')?></th>
            <th data-resizable-column-id="totalRate" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Total Progress')?></th>
            <th data-resizable-column-id="showCount" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Shows')?></th>
            <th data-resizable-column-id="clickCount" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Clicks')?></th>
            <th data-resizable-column-id="clickRate" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Click Rate(%)')?></th>
            <!-- <th data-resizable-column-id="cpm" data-search="on" data-filter="on">CPM</th> -->
            <th data-resizable-column-id="cpc" data-search="on" data-filter="on">CPC</th>
            <th data-resizable-column-id="modifiedDate" data-search="on" data-filter="on"><?=\Yii::t('solution', 'Update Time')?></th>
            <th class="tab-op" data-resizable-column-id="operate" data-filter="on"><?=\Yii::t('solution', 'Actions')?></th>
          </tr>
        </thead>
        <tbody>
          <tr role="row">
            <td class="text-center dataTables_empty" colspan="18"><?=\Yii::t('site', 'No Records')?></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>
<?php
  //$dataList = Yii::getAlias('@web').'/response/solution/solutionDataList.php';
  $dataList = Url::to(['get-all-solutions', 'campaign_id' => $campaign_id]);
  $editMobileUrl = Url::to(['solution-basic-edit']);
  $editPcUrl = Url::to(['pc-solution-basic-edit']);
  $creativeLinkUrl = Url::to(['creative/creative-list']);
  $listPauseOpUrl = Url::to(['list-operate-handle']);
  $listResumeOpUrl = Url::to(['list-operate-handle']);
  !$_SESSION['advertiser_id'] && $isAllBrand = true;
  $_SESSION['advertiser_id'] && $isAllBrand = false;
  $filter = '';    // 需要屏蔽数据时 $dataFilter = ''， 显示数据 $dataFilter = true
  $this->registerJs("VAM.setVar('FILTER_STATUS','$filter');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('STRATEGY_DATA_LIST','$dataList');", View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_MOBILE_EDIT_URL','$editMobileUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_PC_EDIT_URL','$editPcUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('LINK_URL','$creativeLinkUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('LIST_PAUSE_OP_URL', '$listPauseOpUrl')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('LIST_RESUME_OP_URL', '$listResumeOpUrl')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('IS_ALL_BRAND','$isAllBrand');",View::POS_HEAD);
?>
<script type="text/javascript" >
  requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/solution/solutionList.js"]);
  });
</script>
